package stringbuilder;

/*
 * 测试可变字符序列:stringbuilder(线程不安全,效率高), stringbuffer(线程安全,效率低)
 */
public class Test01 {
    public static void main(String[] args) {
        StringBuilder s = new StringBuilder();  //字符数组初始长度为16
        StringBuilder s2 = new StringBuilder(32);  //字符数组初始长度为32
        StringBuilder s3 = new StringBuilder("abcd");
        s2.append("efgh");
        System.out.println(s2.length());
        s2.append(true).append(3123).append("随便");     //通过return this实现方法链
        System.out.println(s2);
        System.out.println("###########################");
        StringBuilder asd = new StringBuilder("a");
        for (int i = 0; i < 1000; i++) {
            asd.append(i);
        }
        System.out.println(asd);
    }
}
